/*
 * @Description:
 * @Author: lz
 * @Date: 2022-12-22 21:02:15
 * @LastEditTime: 2022-12-29 22:05:02
 * @LastEditors: lz
 */
import { getMatterNotice, getProblemNotification } from '@/api/commonApi.js'
const state = {
  sidebar: {},
  roleType: localStorage.getItem('X-Role-Type') - 0 || 0,
  matterNotice: [],
  problemNotification: [],
}

const mutations = {
  M_SET_ROLE_TYPE(state, type) {
    state.roleType = type
  },
  M_SET_NOTICE(state, payload) {
    state.matterNotice = payload
  },
  M_SET_NOTIFICATION(state, payload) {
    state.problemNotification = payload
  },
}

const actions = {
  A_GET_NOTICE({ commit }, data = {}) {
    getMatterNotice(data).then((res) => {
      commit('M_SET_NOTICE', res.data)
    })
  },
  A_GET_NOTIFICATION({ commit }, data = {}) {
    getProblemNotification(data).then((res) => {
      commit('M_SET_NOTIFICATION', res.data)
    })
  },
}

export default {
  namespaced: true,
  state,
  mutations,
  actions,
}
